﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2021_5_20
{
    //创建Calculat基类，其中包含两个整型的protected成员，用以接收用户输入的两个整数。定义一个DisplayResult()虚方法，计算并输出结果。
    #region Calculat基类
    class Calculat
    {
        protected int num1;
        protected int num2;

        public int Num1 { get => num1; set => num1 = value; }
        public int Num2 { get => num2; set => num2 = value; }

        public virtual void DisplayResult() { }

    }
    #endregion

    #region Calculat加法类
    class CalculatForAdd : Calculat
    {
        public override void DisplayResult()
        {
            Console.WriteLine("{0} + {1} = {2}", this.Num1, this.num2, this.Num1 + this.num2);
        }
    }
    #endregion

    #region Calculat减法类
    class CalculatForSub : Calculat
    {
        public override void DisplayResult()
        {
            base.DisplayResult();
            Console.WriteLine("{0}-{1}={2}", Num1, num2, Num1 - num2);
        }
    }
    #endregion

    #region Calculat乘法类
    class CalculatForMul : Calculat
    {
        public override void DisplayResult()
        {
            base.DisplayResult();
            Console.WriteLine("{0}*{1}={2}", Num1, num2, Num1 * num2);
        }
    }
    #endregion

    #region Calculat除法类
    class CalculatForDiv : Calculat
    {
        public override void DisplayResult()
        {
            base.DisplayResult();
            Console.WriteLine("{0}/{1}={2}", Num1, num2, Num1 / num2);
        }
    }
    #endregion
}
